package com.getword.web.controller;


import com.getword.web.model.FileInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/file")
public class FileController {
//    @PostMapping
//    public FileInfo upload(MultipartFile file){
//        System.out.println(file.getName());
//        System.out.println(file.getOriginalFilename());
//        System.out.println(file.getSize());
//        try {
//            InputStream inputStream = file.getInputStream();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        FileInfo fileInfo = new FileInfo("");
//        return fileInfo;
//    }

//    @GetMapping("/{id}")
//    public void download(@PathVariable String id, HttpServletRequest request, HttpServletResponse response) throws Exception {
//        //获取file文件
//        try(InputStream inputStream = new FileInputStream(new File(""));
//            OutputStream out = response.getOutputStream();
//        ){
//            response.setContentType("application/x-download");
//            response.setHeader("Content-Disposition","attachment;filename=test.txt");
//            IOUtils.copy(inputStream, out);
//            out.flush();
//        }
//    }

    @GetMapping("/ext")
    public Object testFile(){
        FileInfo file = new FileInfo();
        file.setFilename("aa.xlsx");
        return file.getExt();
    }
}
